/**
 * @fileOverview base util
 * @author huangtonger@aliyun.com
 */

module.exports = {
  // 矩形是否重叠
  rectRectCrossAlgorithm(r1, r2) {
    const minx = Math.max(r1.minX, r2.minX);
    const miny = Math.max(r1.minY, r2.minY);
    const maxx = Math.min(r1.maxX, r2.maxX);
    const maxy = Math.min(r1.maxY, r2.maxY);
    return minx > maxx || miny > maxy;
  },
  // 欧式距离
  euclideanDistance: {
    // 点与点之间距离
    pointPoint(p1, p2) {
      const sqrDis = Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
      return Math.sqrt(sqrDis);
    }
  }
};
